namespace Part3_IndividuleAssignment2.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class mig01 : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.NewsItems",
                c => new
                    {
                        ID = c.Int(nullable: false, identity: true),
                        Content = c.String(nullable: false, maxLength: 500),
                        PostTime = c.DateTime(nullable: false),
                        Account_ID = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.ID)
                .ForeignKey("dbo.Accounts", t => t.Account_ID, cascadeDelete: true)
                .Index(t => t.Account_ID);
            
            CreateTable(
                "dbo.Accounts",
                c => new
                    {
                        ID = c.Int(nullable: false, identity: true),
                        FirstName = c.String(nullable: false, maxLength: 20),
                        LastName = c.String(nullable: false, maxLength: 20),
                        Email = c.String(nullable: false),
                        City_ID = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.ID)
                .ForeignKey("dbo.Cities", t => t.City_ID, cascadeDelete: true)
                .Index(t => t.City_ID);
            
            CreateTable(
                "dbo.Cities",
                c => new
                    {
                        ID = c.Int(nullable: false, identity: true),
                        CityName = c.String(nullable: false),
                        Province_ID = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.ID)
                .ForeignKey("dbo.Provinces", t => t.Province_ID, cascadeDelete: true)
                .Index(t => t.Province_ID);
            
            CreateTable(
                "dbo.Provinces",
                c => new
                    {
                        ID = c.Int(nullable: false, identity: true),
                        ProvinceName = c.String(nullable: false),
                    })
                .PrimaryKey(t => t.ID);
            
        }
        
        public override void Down()
        {
            DropIndex("dbo.Cities", new[] { "Province_ID" });
            DropIndex("dbo.Accounts", new[] { "City_ID" });
            DropIndex("dbo.NewsItems", new[] { "Account_ID" });
            DropForeignKey("dbo.Cities", "Province_ID", "dbo.Provinces");
            DropForeignKey("dbo.Accounts", "City_ID", "dbo.Cities");
            DropForeignKey("dbo.NewsItems", "Account_ID", "dbo.Accounts");
            DropTable("dbo.Provinces");
            DropTable("dbo.Cities");
            DropTable("dbo.Accounts");
            DropTable("dbo.NewsItems");
        }
    }
}
